fix(checkpoints): resolve incorrect commit location when GIT_DIR set in Dev Containers #8811
+151
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #4567
Description
This PR fixes checkpoint commits being written to the wrong repository when the user is in a Dev Container with the GIT_DIR environment variable configured.
Implementation approach:
Created a createSanitizedGit() helper function that creates SimpleGit instances with a sanitized environment, explicitly removing git-related environment variables (GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY, GIT_ALTERNATE_OBJECT_DIRECTORIES, GIT_CEILING_DIRECTORIES) before executing git operations. This ensures checkpoint operations always target the intended shadow repository regardless of inherited environment.
The fix is applied at two points:
Key design choices:
Reviewers should note:
Test Procedure
Automated testing:
Added a comprehensive integration test (isolates checkpoint operations from GIT_DIR environment variable) that:
Run the test suite:
npx vitest run services/checkpoints/__tests__/ShadowCheckpointService.spec.tsManual testing:
To verify the fix in a real Dev Container scenario:
pnpm vsixVerification checklist:
Pre-Submission Checklist
Documentation Updates
Get in Touch
Discord:
@ocean.smithImportant
Fixes checkpoint commit misdirection in Dev Containers by sanitizing git environment variables in
ShadowCheckpointService.GIT_DIRis set in Dev Containers by sanitizing the environment.createSanitizedGit()function added to remove git-related environment variables before git operations.create()anddeleteCheckpoint()methods ofShadowCheckpointService.ShadowCheckpointService.spec.tsto verify checkpoint isolation fromGIT_DIR.GIT_DIR, and verifies commits are in shadow repo.simple-git's.env()method to set sanitized environment.This description was created by
for 3e1cbbf. You can customize this summary. It will automatically update as commits are pushed.